﻿#ifndef __MyFFmpegPlayer04_H__
#define __MyFFmpegPlayer04_H__

#include <string>

#include "defs.h"

#ifdef __cplusplus
extern "C" {
#endif
#pragma warning(disable:4819)
#pragma warning(disable:4996)

//#ifndef __STDC_CONSTANT_MACROS
//#define __STDC_CONSTANT_MACROS
//#endif

//#include <libavcodec/avcodec.h>
//#include <libavformat/avformat.h>
//#include <libavutil/avstring.h>
//#include <libavutil/imgutils.h>
//#include <libavutil/opt.h>
//#include <libswscale/swscale.h>
//#include <libswresample/swresample.h>
//
//#include <libswresample/swresample.h>
//#include <libswscale/swscale.h>
//
//#include <SDL.h>
//#include <SDL_thread.h>
#ifdef __cplusplus
}
#endif

typedef enum EnumInitType {
    EIT_UseSDL = 0x00000001,
    EIT_Init_Video = 0x00000002,
    EIT_Init_Audio = 0x00000004,
    EIT_Init_Timer = 0x00000008,

    EIT_Init_SDL_ALL = (EIT_UseSDL | EIT_Init_Video| EIT_Init_Audio | EIT_Init_Timer),

    EIT_UseNetComponent = 0x00000100
}EnumInitType;

class MyFFPlayer04
{
    static bool b_s_net_comp_initialized;
    static bool b_s_sdl_initialized;

    std::string last_error_message;

protected:
    VideoState mediaState;

    static void video_refresh_timer(void * userdata);
    static void schedule_refresh(VideoState * videoState, int delay);
    static int decode_thread(void * arg);
    static Uint32 sdl_refresh_timer_cb(Uint32 interval, void * opaque);

public:
    MyFFPlayer04();
    virtual ~MyFFPlayer04();

    static int Init(EnumInitType type, int log_level, std::string* errorMsg);
    static int uninit();

    int get_error_message(int code, std::string& msg);

    
    

    int open(const std::string& path);
    void close();
};




#endif